package entity;

public class Result {
    private Integer code;
    private Object data;
    private String msg;

    /**
     * 构造方法
     */
    public Result(Object data) {
        this.data = data;
    }

    public Result(Integer code) {
        this.code = code;
    }

    public Result(String msg) {
        this.msg = msg;
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    /**
     * 静态方法
     */
    public static Result success(Object data) {
        return new Result(data);
    }

    public static Result success(Integer code) {
        return new Result(code);
    }

    public static Result success(String msg) {
        return new Result(msg);
    }

    public static Result success(Integer code, String msg) {
        return new Result(code,msg);
    }

    public static Result success(Integer code, Object data) {
        return new Result(code,data);
    }

    public static Result fail(String msg) {
        return new Result(msg);
    }

    public static Result fail(Integer code, String msg) {
        return new Result(code,msg);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", data=" + data +
                ", msg='" + msg + '\'' +
                '}';
    }
}
